﻿Public Class FormInvoiceView

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        Dim frm As New FormInvoiceAdd
        frm.ShowDialog()
    End Sub

    Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
        formSearchByDate.ShowDialog()
    End Sub

    Private Sub FormInvoiceView_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        UI.FormatDataGrid(dgv)
        reload()
    End Sub
    Private Sub reload()
        Cmd.Parameters("@s") = "%" & txtSearch.Text & "%"
        Me.dgv.DataSource = Cmd.ExecuteDataTable("SELECT InvoiceNo,ProductCode,ProductName,CustomerName,StoreName,InvoiceDate,Invd.Qty,Invd.Price,Invd.Amount FROM Invoice Inv INNER JOIN Customer Cu ON Cu.CustomerId = Inv.CustomerId INNER JOIN Store St ON St.StoreId = Inv.StoreId INNER JOIN InvoiceDetail Invd ON Invd.InvoiceId = Inv.InvoiceId INNER JOIN Product Pr ON Invd.ProductId = Pr.ProductId  where InvoiceNo like @s and Inv.Active = 1")
    End Sub

    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txtSearch.TextChanged
        reload()
    End Sub
End Class